home *** CD-ROM | disk | FTP | other *** search
-
- #if !defined(AFX_PACK_H__A2D4CDEA_22B4_11D4_ACF2_00A0CC533D52__INCLUDED_)
- #define AFX_PACK_H__A2D4CDEA_22B4_11D4_ACF2_00A0CC533D52__INCLUDED_
-
- #if _MSC_VER > 1000
- #pragma once
- #endif // _MSC_VER > 1000
-
- #pragma pack (push, 1)
-
- union IP // Size 4 // tried to imitate winsock structure in_addr, while still being compatible
- {
- struct { u_char s_b1,s_b2,s_b3,s_b4; } ;//S_un_b;
- struct { u_short s_w1,s_w2; } ;//S_un_w;
- struct {BYTE a, b, c, d;} ;//old_IP;
- u_long S_addr;
- };
-
- struct XWORD // Size 4
- {
- BYTE a; // 0
- BYTE b; // 1
- BYTE c; // 2
- BYTE d; // 3
- };
-
- struct packet_Header // Size 23
- {
- GUID Guid; // 0 - 15
-
- BYTE Function; // 16
- BYTE TTL; // 17
- BYTE Hops; // 18
-
- XWORD Payload; // 19 - 22
- };
-
- struct packet_Ping // Size 23
- {
- packet_Header Header; // 0 - 22
- };
-
- struct packet_Pong // Size 37
- {
- packet_Header Header; // 0 - 22
-
- WORD Port; // 23 - 24
- IP Host; // 25 - 28
- XWORD FileCount; // 29 - 32
- XWORD FileSize; // 33 - 36
- };
-
- struct packet_Push // Size 47
- {
- packet_Header Header; // 0 - 22;
-
- GUID ClientID; // 23 - 38
- XWORD Index; // 39 - 42
- IP Host; // 43 - 46
- WORD Port; // 47 - 48
- };
-
- struct packet_Query // Size 25+
- {
- packet_Header Header; // 0 - 22
-
- WORD Speed; // 23 - 24
- // Search // 25+
- };
-
- struct packet_QueryReply // Size 34+
- {
- packet_Header Header; // 0 - 22
-
- byte TotalHits; // 23
- WORD Port; // 24 - 25
- IP Host; // 26 - 29
- XWORD Speed; // 30 - 33
- // QueryReplySet // 34+
- };
-
- struct packet_QueryReplySet // Size 8+
- {
- XWORD Index; // 0 - 3
- XWORD Size; // 4 - 7
- //LPSTR FileName // 8+
- };
-
- IP StrtoIP(CString in);
- CString IPtoStr(IP in);
- CString WrdtoStr(WORD in);
- CString DWrdtoStr(DWORD in);
-
- struct QueryItem
- {
- QueryItem() // zero all the variables
- { subsearchMatch = true; excluded = false; Host.S_addr = Size = BytesCompleted = Speed = Index = Handle = IconIndex = SortBy = Reverse = Port = 0; }
-
- CString FileName; // path to remote file
- CString LocalFileName; // local file name in save directory. (for *[2].*, *[3].*, etc)
- CString FileType;
- CString Status;
-
- IP Host;
- WORD Port;
- DWORD Size;
- DWORD BytesCompleted; // Needed for pause / resume of a file
-
- DWORD Speed;
- DWORD Index;
-
- int Handle;
- char TransferType; // 'D' for download, 'U' for upload, its stupid i know, 'bandaid'
-
- int IconIndex;
-
- GUID Guid;
-
- bool subsearchMatch; // if the search result matches any subsearch
- bool excluded; // if the search result should be excluded due to user typing in exclude box
-
- static int SortBy;
- static int Reverse;
-
- inline int operator < (struct QueryItem& first)
- {
- bool bResult;
- switch (SortBy)
- {
- case 3: // Host
- {
- if( IPtoStr(first.Host) > IPtoStr(Host) )
- bResult = 1;
- else if( IPtoStr(first.Host) == IPtoStr(Host) )
- bResult = (first.FileName > FileName);
- else
- bResult = 0;
-
- break;
- }
- case 1: // Size
- {
- if(first.Size > Size)
- bResult = 1;
- else if(first.Size == Size)
- bResult = (first.FileName > FileName);
- else
- bResult = 0;
-
- break;
- }
- case 4: // Speed
- {
- if(first.Speed > Speed)
- bResult = 1;
- else if(first.Speed == Speed)
- bResult = (first.FileName > FileName);
- else
- bResult = 0;
-
- break;
- }
- case 2: // File Type
- {
- if( _stricmp( first.FileType, FileType ) > 0 )
- bResult = 1;
- else if(first.FileType == FileType)
- bResult = (_stricmp( first.FileName, FileName ) > 0 );
- else
- bResult = 0;
-
- break;
- }
- case 0: // Filename
- default:
- {
- bResult = ( _stricmp( first.FileName, FileName ) > 0 );
- break;
- }
- }
-
- return (Reverse ? !bResult : bResult);
- };
- };
-
- struct SharedFile
- {
- CString FileDir;
- CString FileName;
- };
-
- struct BlockedSearch
- {
- CString Name;
- char Permis;
- };
-
- XWORD flipX(XWORD);
- WORD flipW(WORD in);
- XWORD makeX(DWORD);
- DWORD makeD(XWORD);
-
- CString CommaIze(CString in);
- CString GetIconDesc(CString);
-
- // HICON GetIconFromName(CString File); // Deprecated, use the next two functions since they keep a cache of icons
- int GetIconIndexFromName (const CString& file);
- CImageList* GetSharedImageList ();
-
- bool SearchMatch(const char* _psz_search_for, const char* _psz_string_to_search);
-
- union FOUR64BIT
- {
- DWORD64 dw64;
-
- struct
- {
- short i4;
- short i3;
- short i2;
- short i1;
- };
- };
-
- DWORD64 util_GetVersionNumber(LPCTSTR lpstrFilename);
-
-
- #pragma pack (pop)
-
- #endif // !defined(AFX_PACK_H__A2D4CDEA_22B4_11D4_ACF2_00A0CC533D52__INCLUDED_)
-
-